$j=jQuery.noConflict();
$j(document).ready(function()
{	workdays();});
function workdays()
{	//alert(1);
	//$j(".alldays").attr("class", "alldays");	$j(".alldays").click(function(event)
	{
		var id=$j(this).parent().attr("id");
		$j("#NADselect"+id).slideUp(500);
	});
	$j(".notalldays").click(function(event)
	{
		var id=$j(this).parent().attr("id");
		$j("#ADselect"+id).slideUp(500);
	});
	$j(".24").click(function(event)
	{
		var id=$j(this).parent().attr("id");
		$j("#ADselect"+id).slideUp(500);
		$j("#NADselect"+id).slideUp(500);
	});
	$j(".alldays").click(function(event)
	{
		var id=$j(this).parent().attr("id");
		//alert(id);
		var ADfrom='\
		c \
		<select size="1" id="fromH'+id+'" name="fromH'+id+'">\
		</select>:\
		<select size="1" id="fromM'+id+'" name="fromM'+id+'">\
		</select>\
		по \
		<select size="1" id="toH'+id+'" name="toH'+id+'">\
		</select>:\
		<select size="1" id="toM'+id+'" name="toM'+id+'">\
		</select>\
		';
		$j("#ADselect"+id).html(ADfrom);
		for(var i=0; i<24; i++)
		{
			var selected="";
			if(i==9)selected="selected";
			if(i<10)
				var hour="0"+i;
			else
				hour=i;
			$j("#fromH"+id).append('<option value="'+hour+'" '+selected+'>'+hour+'</option>');
			var selected="";
			if(i==20)selected="selected";
			$j("#toH"+id).append('<option value="'+hour+'" '+selected+'>'+hour+'</option>');
		}
		for(var i=0; i<60; i++)
		{
			if(i<10)
				var minute="0"+i;
			else
				minute=i;
			$j("#fromM"+id).append('<option value="'+minute+'">'+minute+'</option>');
			$j("#toM"+id).append('<option value="'+minute+'">'+minute+'</option>');
		}
        $j("#ADselect"+id).css("display", "none");
        $j("#ADselect"+id).slideDown(500);
         $j("#"+id+"24").click(function()
         {
         	 $j("#ADselect"+id).slideUp(500);
         });
         $j("#"+id+"notalldays").click(function()
         {
         	 $j("#ADselect"+id).slideUp(500);
         });
	});
	$j(".notalldays").click(function(event)
	{
		var id=$j(this).parent().attr("id");
		var checkDays='\
		<div id="'+id+'mon">\
			<input class="weekdays" id="'+id+'monInput" name="'+id+'days[]" type="checkbox" value="'+id+'mon">Пн\
		</div>\
		<div id="'+id+'tue">\
			<input class="weekdays" id="'+id+'tueInput" name="'+id+'days[]" type="checkbox" value="'+id+'tue">Вт\
		</div>\
		<div id="'+id+'wed">\
			<input class="weekdays" id="'+id+'wedInput" name="'+id+'days[]" type="checkbox" value="'+id+'wed">Ср\
		</div>\
		<div id="'+id+'thi">\
			<input class="weekdays" id="'+id+'thiInput" name="'+id+'days[]" type="checkbox" value="'+id+'thi">Чт\
		</div>\
		<div id="'+id+'fri">\
			<input class="weekdays" id="'+id+'friInput" name="'+id+'days[]" type="checkbox" value="'+id+'fri">Пт\
		</div>\
		<div id="'+id+'sat">\
			<input class="weekdays" id="'+id+'satInput" name="'+id+'days[]" type="checkbox" value="'+id+'sat">Сб\
		</div>\
		<div id="'+id+'sun">\
			<input class="weekdays" id="'+id+'sunInput" name="'+id+'days[]" type="checkbox" value="'+id+'sun">Вс\
		</div>\
		';
		$j("#NADselect"+id).html(checkDays);
		$j("#NADselect"+id).slideDown(500);
		$j(".weekdays").one("click", function(event)
		{
			var weekdayId=$j(this).parent().attr("id");
			var weekday=$j(this).parent();
			var chooseTime='\
			c \
			<select size="1" id="fromH'+weekdayId+'" name="fromH'+weekdayId+'">\
			</select>:\
			<select size="1" id="fromM'+weekdayId+'" name="fromM'+weekdayId+'">\
			</select>\
			по \
			<select size="1" id="toH'+weekdayId+'" name="toH'+weekdayId+'">\
			</select>:\
			<select size="1" id="toM'+weekdayId+'" name="toM'+weekdayId+'">\
			</select>\
			';
			$j(weekday).append('<div id="'+weekdayId+'chooseTime" style="display: none;">'+chooseTime+'</div>');
			for(var i=0; i<24; i++)
			{
				var selected="";
				if(i==9)selected="selected";
				if(i<10)
					var hour="0"+i;
				else
					hour=i;
				$j("#fromH"+weekdayId).append('<option value="'+hour+'" '+selected+'>'+hour+'</option>');
				var selected="";
				if(i==20)selected="selected";
				$j("#toH"+weekdayId).append('<option value="'+hour+'" '+selected+'>'+hour+'</option>');
			}
			for(var i=0; i<60; i++)
			{
				if(i<10)
					var minute="0"+i;
				else
					minute=i;
				$j("#fromM"+weekdayId).append('<option value="'+minute+'">'+minute+'</option>');
				$j("#toM"+weekdayId).append('<option value="'+minute+'">'+minute+'</option>');
			}
			$j("#"+weekdayId+"chooseTime").slideDown(500);
			/*$j(".break").one("click", function(event)
			{
				var breakId=$j(this).attr("id");
				var breakTime=$j("#"+breakId+"Time");
				var chooseBreakTime='\
				c \
				<select size="1" id="fromH'+breakId+'" name="fromH'+breakId+'">\
				</select>:\
				<select size="1" id="fromM'+breakId+'" name="fromM'+breakId+'">\
				</select>\
				по \
				<select size="1" id="toH'+breakId+'" name="toH'+breakId+'">\
				</select>:\
				<select size="1" id="toM'+breakId+'" name="toM'+breakId+'">\
				</select>\
				';
				$j(breakTime).append(chooseBreakTime);
				for(var i=0; i<24; i++)
				{
					var selected="";
					if(i==13)selected="selected";
					if(i<10)
						var hour="0"+i;
					else
						hour=i;
					$j("#fromH"+breakId).append('<option value="'+hour+'" '+selected+'>'+hour+'</option>');
					var selected="";
					if(i==14)selected="selected";
					$j("#toH"+breakId).append('<option value="'+hour+'" '+selected+'>'+hour+'</option>');
				}
				for(var i=0; i<60; i++)
				{
					if(i<10)
						var minute="0"+i;
					else
						minute=i;
					$j("#fromM"+breakId).append('<option value="'+minute+'">'+minute+'</option>');
					$j("#toM"+breakId).append('<option value="'+minute+'">'+minute+'</option>');
				}
				$j(".break").click(function(event)
				{
					var breakId=$j(this).attr("id");
					var breakTime=$j("#"+breakId+"Time");
					$j(breakTime).slideToggle(500);
				});
			});*/

			$j("#"+weekdayId+"Input").click(function()
			{
				$j("#"+weekdayId+"chooseTime").slideToggle(500);
			});
		});
		$j("#"+id+"24").click(function()
         {
         	 $j("#NADselect"+id).slideUp(500);
         });
         $j("#"+id+"alldays").click(function()
         {
         	 $j("#NADselect"+id).slideUp(500);
         });
	});
	$j(".weekdays").one("click", function(event)
		{
			var weekdayId=$j(this).parent().attr("id");
			var weekday=$j(this).parent();
			var chooseTime='\
			c \
			<select size="1" id="fromH'+weekdayId+'" name="fromH'+weekdayId+'">\
			</select>:\
			<select size="1" id="fromM'+weekdayId+'" name="fromM'+weekdayId+'">\
			</select>\
			по \
			<select size="1" id="toH'+weekdayId+'" name="toH'+weekdayId+'">\
			</select>:\
			<select size="1" id="toM'+weekdayId+'" name="toM'+weekdayId+'">\
			</select>\
			';
			$j(weekday).append('<div id="'+weekdayId+'chooseTime" style="display: none;">'+chooseTime+'</div>');
			for(var i=0; i<24; i++)
			{
				var selected="";
				if(i==9)selected="selected";
				if(i<10)
					var hour="0"+i;
				else
					hour=i;
				$j("#fromH"+weekdayId).append('<option value="'+hour+'" '+selected+'>'+hour+'</option>');
				var selected="";
				if(i==20)selected="selected";
				$j("#toH"+weekdayId).append('<option value="'+hour+'" '+selected+'>'+hour+'</option>');
			}
			for(var i=0; i<60; i++)
			{
				if(i<10)
					var minute="0"+i;
				else
					minute=i;
				$j("#fromM"+weekdayId).append('<option value="'+minute+'">'+minute+'</option>');
				$j("#toM"+weekdayId).append('<option value="'+minute+'">'+minute+'</option>');
			}
			$j("#"+weekdayId+"chooseTime").slideDown(500);
			$j("#"+weekdayId+"Input").click(function()
			{
				$j("#"+weekdayId+"chooseTime").slideToggle(500);
			});
		});}